﻿using AbpEntityFrameworkcore.DbContext;
using AbpToDomain;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.DependencyInjection;
using Volo.Abp.Modularity;

namespace AbpEntityFrameworkcore
{

    [DependsOn(
        typeof(AbpEntityFrameworkCoreModule),
        typeof(AbpToDomainModule)           
            )]
    public class AbpEntityFrameworkcoreModule:AbpModule
    {
       
        public override void ConfigureServices(ServiceConfigurationContext context)
        {

            string Lmsconnstr = Environment.GetEnvironmentVariable("HNXG_AGV", EnvironmentVariableTarget.Machine);
            string Customconnstr = Environment.GetEnvironmentVariable("HNXG_AGV", EnvironmentVariableTarget.Machine);
            //string Lmsconnstr = ConfigStaticHelper.GetDbConnect();
            //string Customconnstr = ConfigStaticHelper.GetDbConnect();
            Configure<AbpDbContextOptions>(opt =>
            {
                opt.UseSqlServer();//使用sql           
            });
            //配置wms数据库连接
            context.Services.AddAbpDbContext<MyDbContext>(opt =>
            {
                opt.AddDefaultRepositories(true);//打开默认仓储

            });
            Configure<AbpDbConnectionOptions>(opt =>
            {

                opt.ConnectionStrings["Lmsconnstr"] = Lmsconnstr;//配置连接字符串

            });


            //配置客户数据库连接
            context.Services.AddAbpDbContext<CustomDbContext>(opt =>
            {
                opt.AddDefaultRepositories(true);//打开仓储    
            });
            Configure<AbpDbConnectionOptions>(opt =>
            {

                opt.ConnectionStrings["Customconnstr"] = Customconnstr;//配置连接字符串

            });




            Configure<AbpEntityOptions>(options =>
            {









            });


        }

      
    }
}
